efform_onload = function() {
	efRoundDivTabChange_option("ef_tab_y",0);
 
	//efRoundDivTabChange_option("ef_tab_y",1,fundiv); 
	var info = new EiInfo();
	info.set("fdMineId", $('#fdMineId').val());
	info.set("fdParentId", $('#fdParentId').val());
//	EiCommunicator.send("ZMCS04", "query", info, ajax_chang_callback);
//	EiCommunicator.send("ZMCS05", "query", info, ajax_chang_callback2);
	
	efgrid.submitForm("ef_grid_result", "ZM", "ZMCS04","query", true);
	efgrid.submitForm("ef_grid_detail", "ZM", "ZMCS05","query", true);
};
 
var ajax_chang_callback = {
	onSuccess : function(eiInfo) {
		var grid = efgrid.getGridObject("ef_grid_result");
		grid.refresh(eiInfo);
	},
	onFail : function(eMsg) {}
};
var ajax_chang_callback2 = {
	onSuccess : function(eiInfo) {
		var grid = efgrid.getGridObject("ef_grid_detail");
		grid.refresh(eiInfo);
	},
	onFail : function(eMsg) {}
}; 
button_update_onclick = function() {
	if (isSelected("ef_grid_result") == 0)return;
//	efgrid.submitForm("ef_grid_result", "ZM", "ZMCS04", "update", true);
	var info = getSCZXEiInfos("ZMCS04","ef_grid_result");
	if (null != info) { 
		EiCommunicator.send("ZMCS04", "validate", info, validate_callback);
	}
}
button_insert_onclick = function() {
	if (isSelected("ef_grid_result") == 0)return;
//	efgrid.submitForm("ef_grid_result", "ZM", "ZMCS04", "insert", true);
	var info = getSCZXEiInfos("ZMCS04","ef_grid_result");
	if (null != info) { 
		EiCommunicator.send("ZMCS04", "validate", info, validate_callback);
	}
}
button_delete_onclick = function() {
	if (isSelected("ef_grid_result") == 0)return;
	EFConfirm('你确认要删除吗?', '确认框',function(r) {
				if (r)efgrid.submitForm("ef_grid_result", "ZM", "ZMCS04","delete", true);
	});
}
var validate_callback={
		onSuccess:function(eiInfo){
			if(eiInfo.getStatus()==-1){
				EFAlert("操作失败，原因："+eiInfo.getMsg());
			}else{
/*				 efwindow.hide();
				 var grid = efgrid.getGridObject("ef_grid_result");
				 grid.refresh(eiInfo);*/
				var oper="insert";
				if(eiInfo.get("efCurButtonEname")=="UPDATE"){
					oper="update";
				}
				efgrid.submitForm("ef_grid_result", "ZM", "ZMCS04",oper, true);
			}
		},
		onFail:function(eMsg)
		{
			EFAlert("操作失败，原因："+eMsg); 
		}
}
button_insert1_onclick = function() {
	if (isSelected("ef_grid_detail") == 0)return;
//	efgrid.submitForm("ef_grid_detail", "ZM", "ZMCS05", "insert", true);
	var info = getSCZXEiInfos("ZMCS04","ef_grid_detail");
	if (null != info) { 
		EiCommunicator.send("ZMCS05", "validate", info, validate1_callback);
	}
}
button_update1_onclick = function() {
	if (isSelected("ef_grid_detail") == 0)return;
//	efgrid.submitForm("ef_grid_detail", "ZM", "ZMCS05", "update", true);
	var info = getSCZXEiInfos("ZMCS04","ef_grid_detail");
	if (null != info) { 
		EiCommunicator.send("ZMCS05", "validate", info, validate1_callback);
	}
}
button_delete1_onclick = function() {
	if (isSelected("ef_grid_detail") == 0)return;
	EFConfirm('你确认要删除吗?', '确认框',function(r) {
				if (r)efgrid.submitForm("ef_grid_detail", "ZM", "ZMCS05","delete", true);
	});
}
var validate1_callback={
		onSuccess:function(eiInfo){
			if(eiInfo.getStatus()==-1){
				EFAlert("操作失败，原因："+eiInfo.getMsg());
			}else{
/*				 efwindow.hide();
				 var grid = efgrid.getGridObject("ef_grid_result");
				 grid.refresh(eiInfo);*/
				var oper="insert";
				if(eiInfo.get("efCurButtonEname")=="UPDATE1"){
					oper="update";
				}
				efgrid.submitForm("ef_grid_detail", "ZM", "ZMCS05",oper, true);
			}
		},
		onFail:function(eMsg)
		{
			EFAlert("操作失败，原因："+eMsg); 
		}
}
efgrid_afterAddNewRow = function(grid_id) {
	var fdMineId = $('#fdParentId').val();
	var fdParentType = $('#fdParentType').val();
	fdMineId = fdMineId.substring(0, fdMineId.indexOf("_"));
	var grid = efgrid.getGridObject(grid_id);
	var rows = grid.getCheckedRows();
	if (grid_id == "ef_grid_detail") {
		for (var i = 0; i < rows.length; i++) {
			grid.getBlockData().setCell(rows[i], "fdKeyId", "");
			grid.getBlockData().setCell(rows[i], "fdParentId", fdMineId);
	//		grid.setCellValue(rows[i], 1, fdMineId, TYPE_DATA);
//			grid.setCellValue(rows[i], 0, fdMineId, TYPE_DATA);
		}
	} else if (grid_id == "ef_grid_result") {
		for (var i = 0; i < rows.length; i++) {
			grid.getBlockData().setCell(rows[i], "fdKeyId", "");
			grid.getBlockData().setCell(rows[i], "fdParentId", fdMineId);
//			grid.setCellValue(rows[i], 0, fdMineId, TYPE_DATA);
		}
	}
}